﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;
using System.Data.Linq;
using projectManagementWeb.Validations;


namespace projectManagementWeb.Models.Manager
{
    public class deleteProjectModel
    {
        projectmanagementDBDataContext _dbContext = null;
        public deleteProjectModel()
        {
            _dbContext = new projectmanagementDBDataContext();
        }

        [Required(ErrorMessage="Seleccione un Proyecto valido")]
        [Range(1,Int32.MaxValue,ErrorMessage="Debe de seleccionar un proyecto valido")]
        public int ID { get; set; }

        
        public int userID { get; set; }

        public IEnumerable<SelectListItem> ProjectList
        {
            get
            {
                IEnumerable<SelectListItem> projectList = null;
                projectList = _dbContext.spGetAllProjects()
               .Select(i => new SelectListItem
               {
                   Value = i.ID.ToString(),
                   Text = i.name.ToString()
               }).ToList();

                if (projectList == null || projectList.Count() == 0)
                {
                    List<SelectListItem> list = new List<SelectListItem>();
                    list.Add(new SelectListItem
                    {
                        Value = "-1",
                        Text = "No tiene Proyectos validos"
                    });
                    return list;
                }
                return projectList;
            }
        }

    }
}
